#ifndef LADDERLINECHARTVIEWMODEL_HPP
#define LADDERLINECHARTVIEWMODEL_HPP

#include <QObject>
#include <QWidget>
#include <QDateTime>
#include <QList>
#include "assembly/model/LadderLineChartModel.hpp"
#include <QtCharts/QChart>
#include <QtCharts/QValueAxis>
#include <QtCharts/QCategoryAxis>
#include <QTimer>
#include <QGraphicsItem>
#include <QDebug>

class LadderLineChartViewModel : public QObject {
    Q_OBJECT

public:
    explicit LadderLineChartViewModel(QObject *parent = nullptr)
        : QObject(parent), model(new LadderLineChartModel(this)) {
        // 连接 model 的信号到 ViewModel 的信号
        connect(model, &LadderLineChartModel::startTimeChanged, this, &LadderLineChartViewModel::startTimeChanged);
        connect(model, &LadderLineChartModel::endTimeChanged, this, &LadderLineChartViewModel::endTimeChanged);
        connect(model, &LadderLineChartModel::ladderLinesChanged, this, &LadderLineChartViewModel::ladderLinesChanged);
    }

    // 获取开始时间
    QDateTime getStartTime() const {
        return model-> getStartTime();
    }

    // 获取结束时间
    QDateTime getEndTime() const {
        return model-> getEndTime();
    }

    QList<LadderLineCarrier> getLadderLines() const {
        return model->getLadderLines();
    }

    // 设置 DurationCarrier 数据
    void setLadderLines(const QList<LadderLineCarrier>& newLadderLines) {
        model->setLadderLines(newLadderLines);
    }


signals:
    void startTimeChanged(const QDateTime &newStartTime);
    void endTimeChanged(const QDateTime &newEndTime);
    void ladderLinesChanged(const QList<LadderLineCarrier> &ladderLines);

private:
    LadderLineChartModel *model;
};

#endif // LADDERLINECHARTVIEWMODEL_HPP
